package com.ruoyi.machine.service.impl;

import com.ruoyi.machine.domain.Dto.EExpressBoxUsageRecordsDto;
import com.ruoyi.machine.domain.Dto.EExpressBoxesDto;
import com.ruoyi.machine.domain.EExpressBoxes;
import com.ruoyi.machine.domain.Vo.EExpressBoxUsageRecordsVo;
import com.ruoyi.machine.mapper.EExpressBoxUsageRecordsMapper;
import com.ruoyi.machine.mapper.EExpressBoxesMapper;
import com.ruoyi.machine.service.EExpressBoxesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class EExpressBoxesServiceImpl implements EExpressBoxesService {


    @Autowired
    private
    EExpressBoxesMapper boxesMapper;

    @Autowired
    private EExpressBoxUsageRecordsMapper expressBoxUsageRecordsMapper;


    @Override
    public EExpressBoxesDto findBoxById(Integer id) {
        return boxesMapper.findBoxById(id);
    }

//    @Override
//    public Integer list(EExpressBoxUsageRecordsVo vo) {
//        return expressBoxUsageRecordsMapper.count(vo);
//    }

    @Override
    public Integer count(EExpressBoxUsageRecordsVo vo) {
        return expressBoxUsageRecordsMapper.count(vo);
    }

    @Autowired
    private EExpressBoxUsageRecordsMapper eExpressBoxUsageRecordsMapper;
    @Override
    public List<EExpressBoxUsageRecordsDto> list(EExpressBoxUsageRecordsVo vo) {
        return eExpressBoxUsageRecordsMapper.list(vo);
    }

    @Autowired
    private EExpressBoxesMapper expressBoxesMapper;
    @Override
    public void updateBox(EExpressBoxes boxes) {
                if (boxes.getStorageType()==1){
                    BigDecimal bigDecimal=new BigDecimal("-18");
                    boxes.setTemperature(bigDecimal);
                }else {
                    boxes.setTemperature(null);
                }
                expressBoxesMapper.updateBox(boxes);
    }


//    @Override
//    public void updateBox(ExpressBoxes boxes) {
//        if (boxes.getStorageType()==1){
//            BigDecimal bigDecimal = new BigDecimal("-18");
//            boxes.setTemperature(bigDecimal);
//        }else {
//            boxes.setTemperature(null);
//        }
//        expressBoxesMapper.updateBox(boxes);
//    }

    //    @Override
//    public Integer count(ExpressBoxUsageRecordsVo vo) {
//        return expressBoxUsageRecordsMapper.count(vo);
//    }
}
